home *** CD-ROM | disk | FTP | other *** search
/ AOL File Library: 2,801 to 2,900 / aol-file-protocol-4400-2801-to-2900.zip / AOLDLs / C++ Files Library / Linked List Template Classes / Linked Lists Ä.sit / Linked Lists ƒ / General Template Info next >
Text File  |  1995-03-03  |  2KB  |  45 lines

  1. /********************************************************************************************
  2.  
  3.  
  4.     General Symantec C++ template class (generic class) info. for newcomers......
  5.     
  6.     To use a template class, first declare it in standard C++ syntax (usually in a header file)
  7.     and write the routines in a separate file (usually with the cpp or cp extension at the end of
  8.     the file's name)
  9.     
  10.         examples
  11.         
  12.             (saved in "myHeader.h")
  13.             template <myVariableObject> class myTemplateClass {
  14.                 myVariableObject    theObject;
  15.             public:
  16.                 void    SetValue(myVariableObject thisObject);
  17.             };
  18.         
  19.         
  20.             (saved in "myCode.cp")
  21.             
  22.             #include "myHeader.h"
  23.             template <myVariableObject> void myTemplateClass<myVariableObject>::SetValue(myVariableObject thisObject)
  24.             {
  25.                 theObject=thisObject;
  26.             }
  27.             
  28.             where myVariableObject represents the type of variable you'll within the class;
  29.             remember that you can define several variables to be used by the template class -
  30.             for example, template <myVarOb1, myVarOb2, etc>
  31.             
  32.     Now, to create a specific instance of this template class, in a new file, have the following:
  33.     
  34.         include "myCode.cp"
  35.         // other includes here, as necessary
  36.         
  37.         #pragma template_access public
  38.         #pragma template myTemplateClass<short>
  39.         
  40.     Save this file with a "cp" extension, as it will be compiled, and include it with your project.
  41.     You _don't need to include the original "myCope.cp" file because it will be loaded with the
  42.     creation of the actual class from the template class
  43.         
  44. ********************************************************************************************/
  45.